<template>
  <div class="search_warp">
    <h3 class="hot_title">热门搜索</h3>
    <ul>
      <li
      v-for="(item,index) in hotList"
      :key="index"
      @click="sendHot(item.first)"
      >{{item.first}}</li>
    </ul>
  </div>
</template>

<script>
// 导入vuex映射
import { mapState } from 'vuex'
export default {
  name: 'HotSearch',
  computed: {
    ...mapState(['hotList'])
  },
  methods: {
    sendHot (value) { // 点击列表修改搜索框值
      this.$store.dispatch('changSearch', value)
      this.$router.push('/layout/search/songlist')
    }
  },
  mounted () {
    this.$store.dispatch('getHotMusic')// 调用获取热搜函数
  }
}
</script>

<style lang="less" scoped>
.search_warp{
  padding: .4rem .2667rem 0;
  .hot_title{
    font-size: 12px;
    color: #666;
    line-height: 12px;
  }
  ul{
    margin: 10px 0 7px;
    li{
      display: inline-block;
      height: 32px;
      margin-right: 8px;
      margin-bottom: 8px;
      padding: 0 14px;
      font-size: 14px;
      line-height: 32px;
      color: #333;
      border:1px solid #d3d4da;
      border-radius: 32px;
    }
  }
}
</style>
